package com.sicnu.carrent.repository;

import com.sicnu.carrent.domain.Cars;
import java.util.List;
import org.springframework.data.jpa.repository.JpaRepository;
import org.springframework.data.jpa.repository.Query;
import org.springframework.data.repository.query.Param;


/*
*
* spring-data-jpa ，能否执行原生的SQL语句。
* */


public interface CarsRepository extends JpaRepository<Cars,Integer> {


      @Query(value="select distinct brand from cars where type=:typeName",nativeQuery =true)
      List<String> findBrandsByTypeName(@Param("typeName") String typeName);

      //根据类型和品牌查询汽车的集合
      List<Cars> findAllByTypeAndBrand(String type,String brand);
}
